<?php
define('_ROOT', '/home/ronnie/document/sites/tiaoshei/');
define('TMP_ROOT', '/home/ronnie/document/sites/tiaoshei/tmp/');

require '/home/ronnie/document/HapN/HapN/core/Conf.php';
Conf::load(_ROOT.'/conf/hapn.conf.php');

require _ROOT.'/lib/com/Com.php';
Com::init(Conf::get('hapn.com'));



require dirname(__DIR__).'/FileSystem.php';
require _ROOT.'/lib/libutil/LibUtil.php';
$fs = new FileSystem(array(
	'master' => 'localhost:9333',
	'parseWithUrl' => true,
	));
$fileId = $fs->saveImage(realpath('./test.jpg'));
//$fileId = $fs->_getFileId('3,4e2753d91c8b', 650, 487, 2);
var_dump($fileId);

require '/home/ronnie/document/HapN/HapN/core/Log.php';


require _ROOT.'/lib/db/Db.php';
Db::init(Conf::get('db.conf'));
//Db::get('ts_vote')->queryBySql("insert into image values(unhex('".$fileId['hex']."'), ".time().")");
Db::get('ts_vote')->table('image')->saveBody(array(
	'image_id' => $fileId['sql'],
	'create_time' => time(),
	))->insert();
$rows = Db::get('ts_vote')->table('image')
->field(array(
	'hex(image_id) as image_id', 
	'create_time'
))
->where(array('image_id' => $fileId['sql']))
->get();

var_dump($rows[0]);

$ret = $fs->parseFileId($rows[0]['image_id'], true);
var_dump($ret);